#! /usr/bin/python
import sys
from mechanize import Browser
from BeautifulSoup import BeautifulSoup

br = Browser()
for arg in sys.argv[1:]:
    page = br.open("http://paste.ubuntu.org.cn")
    br.select_form(name="editor")
    br.form.add_file(open(arg), filename="image")
    page =  br.submit()
    html = page.read()
    soup =  BeautifulSoup(html)
    image = soup.find("img",alt="Screenshot")
    print arg + " >> "+ "http://paste.ubuntu.org.cn" + image['src']
